import axios from "axios"
// 是否为生产环境
//const isProd = process.env.NODE_ENV === 'production'
// 根据环境判断baseURL
//const apiUrl = isProd ? 'http://hbdm.ehaier.com/' : '/api'
const apiUrl = 'http://hbdm.ehaier.com/'
export const isMock = false
export const isMock2 = false //控制首页右下角和触点弹窗用假数据
/*
 * 带有Static后缀的为静态备选数据
 * todo dialog接口改为正确的
 */
export const API = {

    commentStatic: './data/comment/data.json',
}



//获取口碑弹窗数据
export function queryCommentData() {
    return new Promise((resolve, reject) => {
        if (isMock) {
            axios.get(API.commentStatic).then(res => {
                resolve(res)
            }).catch(err => {
                reject(err)
            })
        } else {
            axios.post(`${apiUrl}digitalEvaluation/hbdmNumberDataofPublicPraise`).then(res => {
                resolve(res)
            }).catch(err => {
                reject(err)
            })
        }
    })
}

//获取地图弹窗页数据
export function queryStoreData() {
    return new Promise((resolve, reject) => {
        if (isMock2) {
            axios.get('./data/storeData/data.json').then(res => {
                resolve(res.data)
            }).catch(err => {
                reject(err)
            })
        } else {
            axios.post(`${apiUrl}OnlineContact/getOnlineContactData`).then(res => {
                resolve(res.data)
            }).catch(err => {
                reject(err)
            })
        }
    })
}

//获取小微-运营质量
export function queryStoreData3(params) {
    return new Promise((resolve, reject) => {
        if (isMock2) {
            let arr = ['top.json', 'mid.json', 'bottom.json']
            axios.get(`./data/storeData/${arr[params.query]}`).then(res => {

                resolve(res.data)
            }).catch(err => {
                reject(err)
            })
        } else {
            axios.post(`${apiUrl}OnlineContact/getOperaQualData`, params).then(res => {
                resolve(res.data)
            }).catch(err => {
                reject(err)
            })
        }
    })
}
